/*
    Project Milestone 3
    by Lorenzo Miori [Lorenzo.Miori@stud-inf.unibz.it,
    Matteo Angriman [Matteo.Angriman@stud-inf.unibz.it],
    Nick Preda [Nicolae.Preda@stud-inf.unibz.it]
*/

package DB;

import java.sql.Connection;
import java.util.HashMap;

/**
 *
 * @author Nick
 */
public class BookingDB extends GenericTableInterface {
    /* Attribute names to be used in SQL query */
    public static final String BOOKING_TABLE_NAME = "Booking";
    public static final String BOOKING_ID = "booking_id";
    public static final String BOOKING_STATE = "booking_state";
    public static final String BOOK_FROM_DATE = "book_from_date";
    public static final String BOOK_TO_DATE = "book_to_date";
    public static final String BOOK_REQUEST_DATE = "book_request_date";
    public static final String BOOK_ORDER[] = {BOOKING_ID, BOOKING_STATE, BOOK_FROM_DATE, BOOK_TO_DATE, BOOK_REQUEST_DATE};
    /* Attribute types */
    public static final int[] BOOKING_TYPES = {INT, DATE, DATE, DATE, DATE};
    
    public BookingDB(Connection dbConnection){
        /* The generic interface wants to know some stuff...
         * Basic datatypes, the elementary attribute names
         */
        super(dbConnection, BOOKING_TYPES, BOOKING_ID,
                                BOOKING_TABLE_NAME, BOOK_ORDER);
    }
    
    public static String formatBooking(HashMap<String, String> addrData) {
        return "id: "+addrData.get(BookingDB.BOOKING_ID) + ", " +
               "state: "+addrData.get(BookingDB.BOOKING_STATE) + " " +
               "from: "+addrData.get(BookingDB.BOOK_FROM_DATE) + ", " +
               "to: "+addrData.get(BookingDB.BOOK_TO_DATE) + ", " +
               "requested: "+addrData.get(BookingDB.BOOK_REQUEST_DATE) ;
    }
}
